package ch11_11_4;

class Student extends Person implements Comparable<Object>, Cloneable {
		// Variables
		private String major;

		// Constructors
		public Student(Name name) {
			super(name);
			major = "Computer Science";
		}

		// Default Constructor
		public Student() {

		}

		// Instance Methods
		public String getMajor() {
			return major;
		}

		public void setMajor(String major) {
			this.major = major;
		}

		public String toString() {
			Name name = this.getName();
			return name.getFullName() + '\n' + "Major: " + major;
		}

		public boolean equals(Object object) {
			Name name = this.getName();
			Name otherName = ((Student) object).getName();

			if ((name.getFullName().equals(otherName.getLastname()))
					&& (major.equals(((Student) object).getMajor()))) {
				return true;
			}
			return false;
		}

		/** Compare studnet's major, then last name */
		public int compareTo(Object object) {
			if (major.compareTo(((Student) object).major) == 0) {
				return super.compareTo(object);
			} else {
				return major.compareTo(((Student) object).major);
			}
		}
	}